package service.login.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import dao.login.LoginDao;
import entities.login.User;
import service.login.LoginService;

@Service
@Transactional
public class LoginServiceImpl implements LoginService {
      @Resource
      private  LoginDao loginDao;
      
      @Override
      public boolean login(String name,String password,HttpServletRequest req){
    	  List<User> userList=loginDao.login(name,password);
    	  if(userList.size()==0){
    		 return false; 
    	  }
    	  req.getSession().setAttribute("isLogin",true);
 		  req.getSession().setAttribute("user",userList.get(0));
    	  return true;
      }
}
